import uniqueId from '@form-create/utils/lib/unique';
import {localeProps, makeOptionsRule, makeRequiredRule} from '../../utils/index';

const label = '组织选择';
const name = 'jd-org';

export default {
    icon: 'icon-org',
    label,
    name,
    rule({t}) {
        const opt = t('props.option');
        return {
            type: 'Jd-Org',
            field: 'ZZXZ',
            title: '组织选择',
            info: '',
            $required: false,
            validate: false,
            style: { width: '100%'},
            props: {},
        };
    },
    watch: {
        multiple({rule}) {
            rule.key = uniqueId();
        }
    },
    props(_, {t}) {
        return localeProps(t, name + '.props', [
            {type: 'input', field: 'placeholder', title: '占位文本'}, 
            makeRequiredRule(),
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'switch', field: 'showAllLevels', title: '完整路径', value: true}, 
                ]
            },
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'input', field: 'separator', title: '选项分隔符', props: {min: 0, max: 500, controlsPosition:'right', width: '100%'}}
                ]
            }, 
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'switch', field: 'disabled', title: '是否禁用'}, 
                ]
            },
            {
                type: 'col',
                props: {span: 12},
                children: [
                    {type: 'switch', field: 'clearable', title: '允许清除'}, 
                ]
            },
        ])
    }
};